/**
 * 
 */
package com.novatialabs.qttt.gwt.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author nchalko
 * 
 */
public class MoveWidget extends Composite {
  interface MyUiBinder extends UiBinder<Widget, MoveWidget> {}
  private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

  private static final String DEFUALT_TEXT = "";
 
  private final int turnNumber;
  private final Notation formater = new GwtHistoryDisplayNotation();
  
  @UiField Label number;
  @UiField Label description;

  public MoveWidget(int turn) {
    assert (turn > 0 && turn < 10);
    initWidget(uiBinder.createAndBindUi(this));
    this.turnNumber = turn;
    number.setText(String.valueOf(turn));
  }

  public void setMove(Move move) {
    if (move == null) {
      description.setText(DEFUALT_TEXT);
    } else {
      description.setText(formater.printMove(move));
    }

  }

}
